package facilius.controller.action.curso;

import facilius.model.ServiceLocator;
import facilius.model.pojo.Curso;
import org.mentawai.core.BaseAction;

/**
 *
 * @author Graciano
 */
public class CursoShowFormAction extends BaseAction {

    @Override
    public String execute() throws Exception {
        String consequence = ERROR;
        String formAction = "CursoCreate.mtw";
        try {
            Long id = input.getLong("id");
            if (id != null && id > 0) {
                formAction = "CursoUpdate.mtw";
                Curso curso = ServiceLocator.getCursoService().readById(id);

                output.setValue("id", id);
                output.setValue("descricao", curso.getDescricao());
            }

            output.setValue("formAction", formAction);

            consequence = SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return consequence;
    }
}
